package com.liu.HomeWork;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;

/**
 * 服务端
 */
public class HomeWork01Server {
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(6666);
        Socket socket = serverSocket.accept();
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        String s = bufferedReader.readLine();
        BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
        if(s.equals("name")){
        bufferedWriter.write("波妞的海");
        bufferedWriter.newLine();
        bufferedWriter.flush();
            System.out.println(s);
        }else if(s.equals("hobby")){
            bufferedWriter.write("编写java程序");
            bufferedWriter.newLine();
            bufferedWriter.flush();
            System.out.println(s);
        }else {
            bufferedWriter.write("你说的啥");
            bufferedWriter.newLine();
            bufferedWriter.flush();
        }

        String s2 = bufferedReader.readLine();
        if(s2.equals("name")){
            bufferedWriter.write("波妞的海");
            bufferedWriter.newLine();
            bufferedWriter.flush();
            System.out.println(s2);
        }else if(s2.equals("hobby")){
            bufferedWriter.write("编写java程序");
            bufferedWriter.newLine();
            bufferedWriter.flush();
            System.out.println(s2);
        }else {
            bufferedWriter.write("你说的啥");
            bufferedWriter.newLine();
            bufferedWriter.flush();
        }


        serverSocket.close();
        bufferedReader.close();
        bufferedWriter.close();

    }
}
